<?php
require 'db.php';
$perpage = 2;
$total_num = 4;
$total_page = ceil($total_num/$perpage);

$page = isset($_GET['page']) ? $_GET['page'] :1;
$page = max($page,1);
$page = min($page,$total_page);

$strsql = "select * from student left join major on student.major = major.Id";
$strsql .=" limit ".($page-1)*$perpage.", ".$perpage;

$result = mysqli_query($link, $strsql);
$data = mysqli_fetch_all($result);

mysqli_free_result($result);
mysqli_close($link);
require 'fenye02.html';
require 'showdata.html';
?>